
class Global {
  constructor () {
  }

  // server = "http://192.168.43.209:8080/";//熊润
  server = "http://47.92.227.185:8080/"//ali云

  sendDate(url,data,sucFun,type = 'GET'){
    var timestamp = (new Date()).valueOf();
    var token = md5("epms" + timestamp);

    $.ajax({
      url: url,
      data: data,
      method:type,
      headers: {
          token: token,
          timestamp: timestamp
      },
      success: function (res) {
          sucFun(res);
      },
      error: function (err) {
          console.log(err);
      }
    })
  }
  postData(url,data,sucFun){

  }
  getData(key){
    /*
    从session取出数据
     */
    var dataJson = sessionStorage.getItem(key)
    var data = JSON.parse(dataJson)
    console.log('---\n'+(data))
    return data;
  }
  // var projectStatusMap = ['已完成','暂停','终止','进行中']
  // var periodStatusMap = ['创建成功','建模结束','渲染结束','后期结束','验收结束']
  // var typeMap = ['大型','中型','小型','微型']
  ProjectStatus2Digit(s){
    if(s=="已完成"){
      return 0;
    }else if(s=="暂停"){
      return 1;
    }else if(s=="终止"){
      return 2;
    }else if(s=="进行中"){
      return 3;
    }
    return s;
  }

  PeriodStatus2Digit(s){
    if(s == "创建成功"){
      return 0;
    }else if(s =="建模结束"){
      return 1;
    }else if(s =="渲染结束"){
      return 2;
    }else if(s =="后期结束"){
      return 3;
    }else if(s =="验收结束"){
      return 4;
    }
    return s;
  }

  ProjectType2Digit(type){
    console.log(type)
    if(type === "大型"){
      return "0";
    }
    if(type === "中型"){
      return "1";
    }
    if(type === "小型"){
      return "2";
    }
    if(type === "微型"){
      return "3";
    }
    return type;
  }

  storeData (key, data) {
    /*
    存储数据到session
     */

    sessionStorage.setItem(key,JSON.stringify(data))
  }



}

export default Global;//导出

